$('.sam').click(function(){
    $('.xbox1').css('display','block')
    $('.sam').css('color','#f60')
     $('.xbox2').css('display','none')
      $('.dnl').css('color','#666')
})
$('.dnl').click(function(){
    $('.xbox2').css('display','block')
     $('.xbox1').css('display','none')
      $('.dnl').css('color','#f60')
      $('.sam').css('color','#666')
})
$().ready(function () {
        // 在键盘按下并释放及提交后验证提交表单
        $("#myform").validate({
          rules: {
            firstname: "required",
            lastname: "required",
            username: {
              required: true,
              isusername: true,
            },
            pwd: {
              required: true,
              ispwd: true,
            },
            repwd: {
              required: true,
              ispwd: true,
              equalTo: "#pwd",
            },
            gender: {
              required: true,
            },
            spam: {
              required: true,
            },
            phone: {
              required: true,
              isPhone: true,
            },
            email: {
              required: true,
              isemail: true,
            },
            city: {
              required: true,
            },
            abstract: {
              required: true,
            },
          },
          messages: {
            firstname: "请输入您的名字",
            lastname: "请输入您的姓氏",
            username: {
              required: "请输入用户名",
            },
            pwd: {
              required: "请输入密码",
            },
            repwd: {
              required: "请输入密码",
              equalTo: "两次密码输入不一致",
            },
            gender: {
              required: "必选一个",
            },
            spam: {
              required: "必选俩个",
              minlength: "必选俩个",
            },
            phone: {
              required: "请输入联系方式",
            },
            email: {
              required: "请输入您的邮箱",
            },
            city: {
              required: "请选择城市",
            },
            abstract: {
              required: "请输入个人介绍",
            },
          },
        });
        // 用户名验证
        jQuery.validator.addMethod(
          "isusername",
          function (value, element) {
            var tel = /^[A-Za-z0-9_-]{6,12}$/;
            return this.optional(element) || tel.test(value);
          },
          "阿巴正确填写用户名"
        );
        // 密码验证
        jQuery.validator.addMethod(
          "ispwd",
          function (value, element) {
            var tel = /^[A-Za-z0-9_-]{8,16}$/;
            return this.optional(element) || tel.test(value);
          },
          "阿巴正确填写密码"
        );
      });